//
//  UITabBarController+makeTabBarHidden.m
//  ZKL_DSCRM
//
//  Created by Song Ques on 13-7-1.
//  Copyright (c) 2013年 Song Ques. All rights reserved.
//

#import "UITabBarController+makeTabBarHidden.h"

@implementation UITabBarController (makeTabBarHidden)

- (void)makeTabBarHidden:(BOOL)hiddn  {
    if ( [self.view.subviews count] < 2 )
        return;
    
    UIView *contentView;
    
    if ( [[self.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
        contentView = [self.view.subviews objectAtIndex:1];
    else
        contentView = [self.view.subviews objectAtIndex:0];
    
    if ( hiddn ){
        contentView.frame = self.view.bounds;
    }
    else{
        contentView.frame = CGRectMake(self.view.bounds.origin.x,
                                       self.view.bounds.origin.y,
                                       self.view.bounds.size.width,
                                       self.view.bounds.size.height - self.tabBar.frame.size.height);
    }
    
    self.tabBar.hidden = hiddn;
}

- (void)makeTabBarHiddenAndHidBack:(BOOL)hiddn
{
    [self makeTabBarHidden:hiddn];
    UIButton *left_button=[UIButton buttonWithType:UIButtonTypeCustom];
    [left_button setHidden:YES];
    UIBarButtonItem *left_Item=[[UIBarButtonItem alloc] initWithCustomView:left_button];
    self.navigationItem.leftBarButtonItem=left_Item;

}

@end
